package test6.testcases;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import test6.publics.LoginUser;
import test6.data.*;

public class LoginTestCase {
	private static final Class<?> UserData = null;
	private WebDriver driver;
	private String baseUrl;
	
	@BeforeMethod
	public void setUp() throws Exception {
		driver = new FirefoxDriver();
		baseUrl = "http://127.0.0.1:1080/WebTours/";
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}
	
	@Test(dataProviderClass=UserData.class,dataProvider="login")
	public void testCase(String name,String password1) throws Exception {
		driver.get(baseUrl);
		String username = name;
		String password = password1;
		
		LoginUser.login(driver,username,password);         //调用登录模块
		Thread.sleep(5000);
		
		//LoginUser.logout(driver);		                   //调用退出模块
	}
	
	@Test(dataProviderClass=UserData.class,dataProvider="register")
	public void testCaseRegister(String username,String password,String passwordConfirm,String firstName,String lastName,String address1,String address2) throws Exception {
		driver.get(baseUrl);
		LoginUser.register(driver, username, password, passwordConfirm, firstName, lastName, address1, address2);
		Thread.sleep(5000);
	}
	@AfterMethod
	public void tearDown() throws Exception {
		driver.quit();
	}


}
